#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsPixmapItem>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QGraphicsScene* scene = new QGraphicsScene(this);
    scene->addLine(50, 50, 100, 100);
    scene->addRect(100, 50, 100, 100);
    scene->addEllipse(50, 100, 100, 100);
    scene->addText("华清远见Qt");

    QGraphicsPixmapItem* pixmapItem = new QGraphicsPixmapItem(QPixmap(":/images/default.png").scaled(100, 100));
    scene->addItem(pixmapItem);

    QList<QGraphicsItem*> itemList = scene->items();
    for(QGraphicsItem* item : itemList){
        item->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
    }
    ui->graphicsView->setScene(scene);

}

MainWindow::~MainWindow()
{
    delete ui;
}
